
  <div class="layui-card">
    <div class="layui-card-body">
      <div class="layui-tab layui-tab-brief" lay-filter="category-list-tabs">
        <ul class="layui-tab-title" style="margin-bottom: 10px;">
        	<li class="layui-this">文学小说</li>
          <li>经管商业</li>
          <li>IT科技</li>
          <li>自我提升</li>
          <li>人文社科</li>
          <li>儿童书籍</li>
          <li>生活艺术</li>
        </ul>
        <div style="padding-bottom: 10px;"></div>
        <div class="layui-tab-content">
          <div class="layui-tab-item layui-show" id="status1">
		        <div style="margin-bottom: 15px;">
	            <button class="layui-btn layuiadmin-btn-tags" data-type="add1">新增二级分类</button> 		   
		        </div>  	
            <table id="LAY-category-list-status1" lay-filter="LAY-category-list-status1"></table>
          </div>
          <div class="layui-tab-item" id="status2">
          	  <div style="margin-bottom: 15px;">
					        <button class="layui-btn layuiadmin-btn-tags" data-type="add2">新增二级分类</button>
			        </div>  
              <table id="LAY-category-list-status2" lay-filter="LAY-category-list-status2"></table>
          </div>
          <div class="layui-tab-item" id="status3">
          	<div style="margin-bottom: 15px;">
				        <button class="layui-btn layuiadmin-btn-tags" data-type="add3">新增二级分类</button>  
				    </div>    
              <table id="LAY-category-list-status3" lay-filter="LAY-category-list-status3"></table>
          </div>
          <div class="layui-tab-item" id="status4">
          	<div style="margin-bottom: 15px;">
				        <button class="layui-btn layuiadmin-btn-tags" data-type="add4">新增二级分类</button>  
				    </div>    
              <table id="LAY-category-list-status4" lay-filter="LAY-category-list-status4"></table>
          </div>
          <div class="layui-tab-item" id="status5">
          	<div style="margin-bottom: 15px;">
				        <button class="layui-btn layuiadmin-btn-tags" data-type="add5">新增二级分类</button>  
				    </div>    
              <table id="LAY-category-list-status5" lay-filter="LAY-category-list-status5"></table>
          </div>
          <div class="layui-tab-item" id="status6">
          	<div style="margin-bottom: 15px;">
				        <button class="layui-btn layuiadmin-btn-tags" data-type="add6">新增二级分类</button>  
				    </div>    
            <table id="LAY-category-list-status6" lay-filter="LAY-category-list-status6"></table>
          </div>
          <div class="layui-tab-item" id="status7">
          	<div style="margin-bottom: 15px;">
				        <button class="layui-btn layuiadmin-btn-tags" data-type="add7">新增二级分类</button> 
				    </div>    
              <table id="LAY-category-list-status7" lay-filter="LAY-category-list-status7"></table>
          </div>
          <script type="text/html" id="LAY-category-list-table-edit">
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>            
          </script>
          <script type="text/html" id="wechat_avatar">
	            <span>{{d.title}}</span>
	            <span>（{{d.count}}本）</span>
	        </script>
        </div>
      </div>
    </div>
  </div>

  
  <script>

    layui.define(['admin', 'table', 'form'], function(exports){
        var table = layui.table
        ,form = layui.form
        ,admin = layui.admin
        ,view = layui.view
        ,element = layui.element
        ,$ = layui.$
        ,curr_tab = 0               //当前tab索引
        ,cols = [[
            {align:'center',field:'title', title: '二级分类名称',templet: '#wechat_avatar',}
            ,{align:'center',field:'sort', title: '排序值'}
            ,{align:'center', fixed: 'right',title: '操作', toolbar: '#LAY-category-list-table-edit'}
          ]];
          table.set({
            headers: { //通过 request 头传递
              'access-token': layui.data('layuiAdmin').access_token
            }
          });
        form.render(null, 'goods-list-form');
        table.render({
          elem: '#LAY-category-list-status1'
          ,url: 'https://bookshop.dingdangtoy.com/api/admin/category/list?pid=1'
          ,parseData: function(res){ //res 即为原始返回的数据
            return {
              "code": res.code, //解析接口状态
              "msg": res.message, //解析提示文本
              "data": res.data //解析数据列表
            }
          }
          ,cols: cols
          ,page: false
        });
        table.render({
          elem: '#LAY-category-list-status2'
          ,url: 'https://bookshop.dingdangtoy.com/api/admin/category/list?pid=2'
          ,parseData: function(res){ //res 即为原始返回的数据
            return {
              "code": res.code, //解析接口状态
              "msg": res.message, //解析提示文本
              "data": res.data //解析数据列表
            }
          }
          ,cols: cols
          ,page: false
        });
        table.render({
          elem: '#LAY-category-list-status3'
          ,url: 'https://bookshop.dingdangtoy.com/api/admin/category/list?pid=3'
          ,parseData: function(res){ //res 即为原始返回的数据
            return {
              "code": res.code, //解析接口状态
              "msg": res.message, //解析提示文本
              "data": res.data //解析数据列表
            }
          }
          ,cols: cols
          ,page: false
        });
        table.render({
          elem: '#LAY-category-list-status4'
          ,url: 'https://bookshop.dingdangtoy.com/api/admin/category/list?pid=4'
          ,parseData: function(res){ //res 即为原始返回的数据
            return {
              "code": res.code, //解析接口状态
              "msg": res.message, //解析提示文本
              "data": res.data //解析数据列表
            }
          }
          ,cols: cols
          ,page: false
        });
        table.render({
          elem: '#LAY-category-list-status5'
          ,url: 'https://bookshop.dingdangtoy.com/api/admin/category/list?pid=5'
          ,parseData: function(res){ //res 即为原始返回的数据
            return {
              "code": res.code, //解析接口状态
              "msg": res.message, //解析提示文本
              "data": res.data //解析数据列表
            }
          }
          ,cols: cols
          ,page: false
        });
        table.render({
          elem: '#LAY-category-list-status6'
          ,url: 'https://bookshop.dingdangtoy.com/api/admin/category/list?pid=6'
          ,parseData: function(res){ //res 即为原始返回的数据
            return {
              "code": res.code, //解析接口状态
              "msg": res.message, //解析提示文本
              "data": res.data //解析数据列表
            }
          }
          ,cols: cols
          ,page: false
        });
        table.render({
          elem: '#LAY-category-list-status7'
          ,url: 'https://bookshop.dingdangtoy.com/api/admin/category/list?pid=7'
          ,parseData: function(res){ //res 即为原始返回的数据
            return {
              "code": res.code, //解析接口状态
              "msg": res.message, //解析提示文本
              "data": res.data //解析数据列表
            }
          }
          ,cols: cols
          ,page: false
        });
      // 监听tab切换
      element.on('tab(category-list-tabs)', function(data){
        curr_tab = data.index
      });
    //监听工具条
    table.on('tool(LAY-category-list-status1)', function(obj){
      var data = obj.data;
      if(obj.event === 'del'){
        layer.confirm('是否删除', function(index){
	   	    $.ajax({
				    type: "DELETE",
				    dataType: "json",
				    url: "https://bookshop.dingdangtoy.com/api/admin/category/destroy",
				    data: {id:data.id},
				    headers: { //通过 request 头传递
		              'access-token': layui.data('layuiAdmin').access_token
		            },
						success: function(data){
						    layer.msg('操作成功');
						    layui.table.reload('LAY-category-list-status1');
				        layer.close(index); //执行关闭 
						},
						error: function(msg){
						  console.log(msg)
						}
				  });
        });
      } else if(obj.event === 'edit'){
          admin.popup({
		        title: '编辑二级分类'
		        ,area: ['550px', '300px']
		        ,id: 'LAY-popup-content-edit'
		        ,success: function(layero, index){
		          view(this.id).render('goods/category/add', data).done(function(){
		            form.render(null, 'layuiadmin-form-tags');
		            
		            //监听提交
		            form.on('submit(layuiadmin-app-tags-submit)', function(data){
		            	
		              var title = data.field.title; //获取提交的字段
		              var category_id = data.field.id;
		              var sort = data.field.sort;
		              //提交 Ajax 成功后，关闭当前弹层并重载表格
					        layer.confirm('是否执行此操作', function(index){
					   	        $.ajax({
								    type: "PUT",
								    dataType: "json",
								    url: "https://bookshop.dingdangtoy.com/api/admin/category/update",
								    data: {pid:1,title:title,id:category_id,sort:sort},
								    headers: { //通过 request 头传递
						              'access-token': layui.data('layuiAdmin').access_token
						            },
											success: function(data){
											    layer.msg('操作成功');
											    layui.table.reload('LAY-category-list-status1');
											},
											error: function(msg){
											  console.log(msg)
											}
									});
					        });		
		              layer.close(index); //执行关闭 
		            });
		          });
		        }
		      });
      }
    });
    table.on('tool(LAY-category-list-status2)', function(obj){
      var data = obj.data;
      if(obj.event === 'del'){
        layer.confirm('是否删除', function(index){
	   	    $.ajax({
				    type: "DELETE",
				    dataType: "json",
				    url: "https://bookshop.dingdangtoy.com/api/admin/category/destroy",
				    data: {id:data.id},
				    headers: { //通过 request 头传递
		              'access-token': layui.data('layuiAdmin').access_token
		            },
						success: function(data){
						    layer.msg('操作成功');
						    layui.table.reload('LAY-category-list-status2');
				        layer.close(index); //执行关闭 
						},
						error: function(msg){
						  console.log(msg)
						}
				  });
        });
      } else if(obj.event === 'edit'){
          admin.popup({
		        title: '编辑二级分类'
		        ,area: ['550px', '300px']
		        ,id: 'LAY-popup-content-edit'
		        ,success: function(layero, index){
		          view(this.id).render('goods/category/add', data).done(function(){
		            form.render(null, 'layuiadmin-form-tags');
		            
		            //监听提交
		            form.on('submit(layuiadmin-app-tags-submit)', function(data){
		            	
		              var title = data.field.title; //获取提交的字段
		              var category_id = data.field.id;
		              var sort = data.field.sort;
		              //提交 Ajax 成功后，关闭当前弹层并重载表格
					        layer.confirm('是否执行此操作', function(index){
					   	        $.ajax({
								    type: "PUT",
								    dataType: "json",
								    url: "https://bookshop.dingdangtoy.com/api/admin/category/update",
								    data: {pid:2,title:title,id:category_id,sort:sort},
								    headers: { //通过 request 头传递
						              'access-token': layui.data('layuiAdmin').access_token
						            },
											success: function(data){
											    layer.msg('操作成功');
											    layui.table.reload('LAY-category-list-status2');
											},
											error: function(msg){
											  console.log(msg)
											}
									});
					        });		
		              layer.close(index); //执行关闭 
		            });
		          });
		        }
		      });
      }
    });
    table.on('tool(LAY-category-list-status3)', function(obj){
      var data = obj.data;
      if(obj.event === 'del'){
        layer.confirm('是否删除', function(index){
	   	    $.ajax({
				    type: "DELETE",
				    dataType: "json",
				    url: "https://bookshop.dingdangtoy.com/api/admin/category/destroy",
				    data: {id:data.id},
				    headers: { //通过 request 头传递
		              'access-token': layui.data('layuiAdmin').access_token
		            },
						success: function(data){
						    layer.msg('操作成功');
						    layui.table.reload('LAY-category-list-status3');
				        layer.close(index); //执行关闭 
						},
						error: function(msg){
						  console.log(msg)
						}
				  });
        });
      } else if(obj.event === 'edit'){
          admin.popup({
		        title: '编辑二级分类'
		        ,area: ['550px', '300px']
		        ,id: 'LAY-popup-content-edit'
		        ,success: function(layero, index){
		          view(this.id).render('goods/category/add', data).done(function(){
		            form.render(null, 'layuiadmin-form-tags');
		            
		            //监听提交
		            form.on('submit(layuiadmin-app-tags-submit)', function(data){
		            	
		              var title = data.field.title; //获取提交的字段
		              var category_id = data.field.id;
		              var sort = data.field.sort;
		              //提交 Ajax 成功后，关闭当前弹层并重载表格
					        layer.confirm('是否执行此操作', function(index){
					   	        $.ajax({
								    type: "PUT",
								    dataType: "json",
								    url: "https://bookshop.dingdangtoy.com/api/admin/category/update",
								    data: {pid:3,title:title,id:category_id,sort:sort},
								    headers: { //通过 request 头传递
						              'access-token': layui.data('layuiAdmin').access_token
						            },
											success: function(data){
											    layer.msg('操作成功');
											    layui.table.reload('LAY-category-list-status3');
											},
											error: function(msg){
											  console.log(msg)
											}
									});
					        });		
		              layer.close(index); //执行关闭 
		            });
		          });
		        }
		      });
      }
    });
    table.on('tool(LAY-category-list-status4)', function(obj){
      var data = obj.data;
      if(obj.event === 'del'){
        layer.confirm('是否删除', function(index){
	   	    $.ajax({
				    type: "DELETE",
				    dataType: "json",
				    url: "https://bookshop.dingdangtoy.com/api/admin/category/destroy",
				    data: {id:data.id},
				    headers: { //通过 request 头传递
		              'access-token': layui.data('layuiAdmin').access_token
		            },
						success: function(data){
						    layer.msg('操作成功');
						    layui.table.reload('LAY-category-list-status4');
				        layer.close(index); //执行关闭 
						},
						error: function(msg){
						  console.log(msg)
						}
				  });
        });
      } else if(obj.event === 'edit'){
          admin.popup({
		        title: '编辑二级分类'
		        ,area: ['550px', '300px']
		        ,id: 'LAY-popup-content-edit'
		        ,success: function(layero, index){
		          view(this.id).render('goods/category/add', data).done(function(){
		            form.render(null, 'layuiadmin-form-tags');
		            
		            //监听提交
		            form.on('submit(layuiadmin-app-tags-submit)', function(data){
		            	
		              var title = data.field.title; //获取提交的字段
		              var category_id = data.field.id;
		              var sort = data.field.sort;
		              //提交 Ajax 成功后，关闭当前弹层并重载表格
					        layer.confirm('是否执行此操作', function(index){
					   	        $.ajax({
								    type: "PUT",
								    dataType: "json",
								    url: "https://bookshop.dingdangtoy.com/api/admin/category/update",
								    data: {pid:4,title:title,id:category_id,sort:sort},
								    headers: { //通过 request 头传递
						              'access-token': layui.data('layuiAdmin').access_token
						            },
											success: function(data){
											    layer.msg('操作成功');
											    layui.table.reload('LAY-category-list-status4');
											},
											error: function(msg){
											  console.log(msg)
											}
									});
					        });		
		              layer.close(index); //执行关闭 
		            });
		          });
		        }
		      });
      }
    });
    table.on('tool(LAY-category-list-status5)', function(obj){
      var data = obj.data;
      if(obj.event === 'del'){
        layer.confirm('是否删除', function(index){
	   	    $.ajax({
				    type: "DELETE",
				    dataType: "json",
				    url: "https://bookshop.dingdangtoy.com/api/admin/category/destroy",
				    data: {id:data.id},
				    headers: { //通过 request 头传递
		              'access-token': layui.data('layuiAdmin').access_token
		            },
						success: function(data){
						    layer.msg('操作成功');
						    layui.table.reload('LAY-category-list-status5');
				        layer.close(index); //执行关闭 
						},
						error: function(msg){
						  console.log(msg)
						}
				  });
        });
      } else if(obj.event === 'edit'){
          admin.popup({
		        title: '编辑二级分类'
		        ,area: ['550px', '300px']
		        ,id: 'LAY-popup-content-edit'
		        ,success: function(layero, index){
		          view(this.id).render('goods/category/add', data).done(function(){
		            form.render(null, 'layuiadmin-form-tags');
		            
		            //监听提交
		            form.on('submit(layuiadmin-app-tags-submit)', function(data){
		            	
		              var title = data.field.title; //获取提交的字段
		              var category_id = data.field.id;
		              var sort = data.field.sort;
		              //提交 Ajax 成功后，关闭当前弹层并重载表格
					        layer.confirm('是否执行此操作', function(index){
					   	        $.ajax({
								    type: "PUT",
								    dataType: "json",
								    url: "https://bookshop.dingdangtoy.com/api/admin/category/update",
								    data: {pid:5,title:title,id:category_id,sort:sort},
								    headers: { //通过 request 头传递
						              'access-token': layui.data('layuiAdmin').access_token
						            },
											success: function(data){
											    layer.msg('操作成功');
											    layui.table.reload('LAY-category-list-status5');
											},
											error: function(msg){
											  console.log(msg)
											}
									});
					        });		
		              layer.close(index); //执行关闭 
		            });
		          });
		        }
		      });
      }
    });
    table.on('tool(LAY-category-list-status6)', function(obj){
      var data = obj.data;
      if(obj.event === 'del'){
        layer.confirm('是否删除', function(index){
	   	    $.ajax({
				    type: "DELETE",
				    dataType: "json",
				    url: "https://bookshop.dingdangtoy.com/api/admin/category/destroy",
				    data: {id:data.id},
				    headers: { //通过 request 头传递
		              'access-token': layui.data('layuiAdmin').access_token
		            },
						success: function(data){
						    layer.msg('操作成功');
						    layui.table.reload('LAY-category-list-status6');
				        layer.close(index); //执行关闭 
						},
						error: function(msg){
						  console.log(msg)
						}
				  });
        });
      } else if(obj.event === 'edit'){
          admin.popup({
		        title: '编辑二级分类'
		        ,area: ['550px', '300px']
		        ,id: 'LAY-popup-content-edit'
		        ,success: function(layero, index){
		          view(this.id).render('goods/category/add', data).done(function(){
		            form.render(null, 'layuiadmin-form-tags');
		            
		            //监听提交
		            form.on('submit(layuiadmin-app-tags-submit)', function(data){
		            	
		              var title = data.field.title; //获取提交的字段
		              var category_id = data.field.id;
		              var sort = data.field.sort;
		              //提交 Ajax 成功后，关闭当前弹层并重载表格
					        layer.confirm('是否执行此操作', function(index){
					   	        $.ajax({
								    type: "PUT",
								    dataType: "json",
								    url: "https://bookshop.dingdangtoy.com/api/admin/category/update",
								    data: {pid:6,title:title,id:category_id,sort:sort},
								    headers: { //通过 request 头传递
						              'access-token': layui.data('layuiAdmin').access_token
						            },
											success: function(data){
											    layer.msg('操作成功');
											    layui.table.reload('LAY-category-list-status6');
											},
											error: function(msg){
											  console.log(msg)
											}
									});
					        });		
		              layer.close(index); //执行关闭 
		            });
		          });
		        }
		      });
      }
    });
    table.on('tool(LAY-category-list-status7)', function(obj){
      var data = obj.data;
      if(obj.event === 'del'){
        layer.confirm('是否删除', function(index){
	   	    $.ajax({
				    type: "DELETE",
				    dataType: "json",
				    url: "https://bookshop.dingdangtoy.com/api/admin/category/destroy",
				    data: {id:data.id},
				    headers: { //通过 request 头传递
		              'access-token': layui.data('layuiAdmin').access_token
		            },
						success: function(data){
						    layer.msg('操作成功');
						    layui.table.reload('LAY-category-list-status7');
				        layer.close(index); //执行关闭 
						},
						error: function(msg){
						  console.log(msg)
						}
				  });
        });
      } else if(obj.event === 'edit'){
          admin.popup({
		        title: '编辑二级分类'
		        ,area: ['550px', '300px']
		        ,id: 'LAY-popup-content-edit'
		        ,success: function(layero, index){
		          view(this.id).render('goods/category/add', data).done(function(){
		            form.render(null, 'layuiadmin-form-tags');
		            
		            //监听提交
		            form.on('submit(layuiadmin-app-tags-submit)', function(data){
		            	
		              var title = data.field.title; //获取提交的字段
		              var category_id = data.field.id;
		              var sort = data.field.sort;
		              //提交 Ajax 成功后，关闭当前弹层并重载表格
					        layer.confirm('是否执行此操作', function(index){
					   	        $.ajax({
								    type: "PUT",
								    dataType: "json",
								    url: "https://bookshop.dingdangtoy.com/api/admin/category/update",
								    data: {pid:7,title:title,id:category_id,sort:sort},
								    headers: { //通过 request 头传递
						              'access-token': layui.data('layuiAdmin').access_token
						            },
											success: function(data){
											    layer.msg('操作成功');
											    layui.table.reload('LAY-category-list-status7');
											},
											error: function(msg){
											  console.log(msg)
											}
									});
					        });		
		              layer.close(index); //执行关闭 
		            });
		          });
		        }
		      });
      }
    });

  //事件
  var active = {
    add1: function(){
      admin.popup({
        title: '添加二级分类'
        ,area: ['450px', '300px']
        ,id: 'LAY-popup-content-tags'
        ,success: function(layero, index){
          view(this.id).render('goods/category/add').done(function(){
            form.render(null, 'layuiadmin-form-tags');
         
            //监听提交
            form.on('submit(layuiadmin-app-tags-submit)', function(data){
              var title = data.field.title; //获取提交的字段
              var sort = data.field.sort;
              //提交 Ajax 成功后，关闭当前弹层并重载表格
			        layer.confirm('是否执行此操作', function(index){
			   	        $.ajax({
						    type: "POST",
						    dataType: "json",
						    url: "https://bookshop.dingdangtoy.com/api/admin/category/store",
						    data: {pid:1,title:title,sort:sort},
						    headers: { //通过 request 头传递
				              'access-token': layui.data('layuiAdmin').access_token
				            },
									success: function(data){
									    layer.msg('操作成功');
									    layui.table.reload('LAY-category-list-status1');
									},
									error: function(msg){
									  console.log(msg)
									}
							});
			        });			         
							 layer.close(index); //执行关闭 
            });
          });
        }
      });
    },
    add2: function(){
      admin.popup({
        title: '添加二级分类'
        ,area: ['450px', '300px']
        ,id: 'LAY-popup-content-tags'
        ,success: function(layero, index){
          view(this.id).render('goods/category/add').done(function(){
            form.render(null, 'layuiadmin-form-tags');
         
            //监听提交
            form.on('submit(layuiadmin-app-tags-submit)', function(data){
              var title = data.field.title; //获取提交的字段
              var sort = data.field.sort;
              //提交 Ajax 成功后，关闭当前弹层并重载表格
			        layer.confirm('是否执行此操作', function(index){
			   	        $.ajax({
						    type: "POST",
						    dataType: "json",
						    url: "https://bookshop.dingdangtoy.com/api/admin/category/store",
						    data: {pid:2,title:title,sort:sort},
						    headers: { //通过 request 头传递
				              'access-token': layui.data('layuiAdmin').access_token
				            },
									success: function(data){
									    layer.msg('操作成功');
									    layui.table.reload('LAY-category-list-status2');
									},
									error: function(msg){
									  console.log(msg)
									}
							});
			        });			         
							 layer.close(index); //执行关闭 
            });
          });
        }
      });
    },
    add3: function(){
      admin.popup({
        title: '添加二级分类'
        ,area: ['450px', '300px']
        ,id: 'LAY-popup-content-tags'
        ,success: function(layero, index){
          view(this.id).render('goods/category/add').done(function(){
            form.render(null, 'layuiadmin-form-tags');
         
            //监听提交
            form.on('submit(layuiadmin-app-tags-submit)', function(data){
              var title = data.field.title; //获取提交的字段
              var sort = data.field.sort;
              //提交 Ajax 成功后，关闭当前弹层并重载表格
			        layer.confirm('是否执行此操作', function(index){
			   	        $.ajax({
						    type: "POST",
						    dataType: "json",
						    url: "https://bookshop.dingdangtoy.com/api/admin/category/store",
						    data: {pid:3,title:title,sort:sort},
						    headers: { //通过 request 头传递
				              'access-token': layui.data('layuiAdmin').access_token
				            },
									success: function(data){
									    layer.msg('操作成功');
									    layui.table.reload('LAY-category-list-status3');
									},
									error: function(msg){
									  console.log(msg)
									}
							});
			        });			         
							 layer.close(index); //执行关闭 
            });
          });
        }
      });
    },
    add4: function(){
      admin.popup({
        title: '添加二级分类'
        ,area: ['450px', '300px']
        ,id: 'LAY-popup-content-tags'
        ,success: function(layero, index){
          view(this.id).render('goods/category/add').done(function(){
            form.render(null, 'layuiadmin-form-tags');
         
            //监听提交
            form.on('submit(layuiadmin-app-tags-submit)', function(data){
              var title = data.field.title; //获取提交的字段
              var sort = data.field.sort;
              //提交 Ajax 成功后，关闭当前弹层并重载表格
			        layer.confirm('是否执行此操作', function(index){
			   	        $.ajax({
						    type: "POST",
						    dataType: "json",
						    url: "https://bookshop.dingdangtoy.com/api/admin/category/store",
						    data: {pid:4,title:title,sort:sort},
						    headers: { //通过 request 头传递
				              'access-token': layui.data('layuiAdmin').access_token
				            },
									success: function(data){
									    layer.msg('操作成功');
									    layui.table.reload('LAY-category-list-status4');
									},
									error: function(msg){
									  console.log(msg)
									}
							});
			        });			         
							 layer.close(index); //执行关闭 
            });
          });
        }
      });
    },
    add5: function(){
      admin.popup({
        title: '添加二级分类'
        ,area: ['450px', '300px']
        ,id: 'LAY-popup-content-tags'
        ,success: function(layero, index){
          view(this.id).render('goods/category/add').done(function(){
            form.render(null, 'layuiadmin-form-tags');
         
            //监听提交
            form.on('submit(layuiadmin-app-tags-submit)', function(data){
              var title = data.field.title; //获取提交的字段
              var sort = data.field.sort;
              //提交 Ajax 成功后，关闭当前弹层并重载表格
			        layer.confirm('是否执行此操作', function(index){
			   	        $.ajax({
						    type: "POST",
						    dataType: "json",
						    url: "https://bookshop.dingdangtoy.com/api/admin/category/store",
						    data: {pid:5,title:title,sort:sort},
						    headers: { //通过 request 头传递
				              'access-token': layui.data('layuiAdmin').access_token
				            },
									success: function(data){
									    layer.msg('操作成功');
									    layui.table.reload('LAY-category-list-status5');
									},
									error: function(msg){
									  console.log(msg)
									}
							});
			        });			         
							 layer.close(index); //执行关闭 
            });
          });
        }
      });
    },
    add6: function(){
      admin.popup({
        title: '添加二级分类'
        ,area: ['450px', '300px']
        ,id: 'LAY-popup-content-tags'
        ,success: function(layero, index){
          view(this.id).render('goods/category/add').done(function(){
            form.render(null, 'layuiadmin-form-tags');
         
            //监听提交
            form.on('submit(layuiadmin-app-tags-submit)', function(data){
              var title = data.field.title; //获取提交的字段
              var sort = data.field.sort;
              //提交 Ajax 成功后，关闭当前弹层并重载表格
			        layer.confirm('是否执行此操作', function(index){
			   	        $.ajax({
						    type: "POST",
						    dataType: "json",
						    url: "https://bookshop.dingdangtoy.com/api/admin/category/store",
						    data: {pid:6,title:title,sort:sort},
						    headers: { //通过 request 头传递
				              'access-token': layui.data('layuiAdmin').access_token
				            },
									success: function(data){
									    layer.msg('操作成功');
									    layui.table.reload('LAY-category-list-status6');
									},
									error: function(msg){
									  console.log(msg)
									}
							});
			        });			         
							 layer.close(index); //执行关闭 
            });
          });
        }
      });
    },
    add7: function(){
      admin.popup({
        title: '添加二级分类'
        ,area: ['450px', '300px']
        ,id: 'LAY-popup-content-tags'
        ,success: function(layero, index){
          view(this.id).render('goods/category/add').done(function(){
            form.render(null, 'layuiadmin-form-tags');
         
            //监听提交
            form.on('submit(layuiadmin-app-tags-submit)', function(data){
              var title = data.field.title; //获取提交的字段
              var sort = data.field.sort;
              //提交 Ajax 成功后，关闭当前弹层并重载表格
			        layer.confirm('是否执行此操作', function(index){
			   	        $.ajax({
						    type: "POST",
						    dataType: "json",
						    url: "https://bookshop.dingdangtoy.com/api/admin/category/store",
						    data: {pid:7,title:title,sort:sort},
						    headers: { //通过 request 头传递
				              'access-token': layui.data('layuiAdmin').access_token
				            },
									success: function(data){
									    layer.msg('操作成功');
									    layui.table.reload('LAY-category-list-status7');
									},
									error: function(msg){
									  console.log(msg)
									}
							});
			        });			         
							 layer.close(index); //执行关闭 
            });
          });
        }
      });
    }    
  };

  $('.layui-btn.layuiadmin-btn-tags').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });  
      })
  
  </script>